var app = getApp()
var utils = require('../../utils/utils.js')
Page( {
  data: {
     bind:false
  },
  onLoad: function() {
    var that = this
    // 获取用户信息
    wx.login({
      success: function (res) {
        //调用后台接口
        var param ={"code":res.code,"appId":app.globalData.appId};
        wx.request({
          url: utils.sysConst.getDeliveryClerkInfoPath,
          method: 'POST',
          header: {
            "Content-Type": "application/x-www-form-urlencoded",'appVersion':utils.appVersion,'signValue':utils.getSignValue(param)
          },
          data: param,
          dataType: "json",
          success: function(res) {
            if (res.data.code == 1){
              //设置全局用户信息-openid
              app.globalData.openid = res.data.data.openId
              if(res.data.data.register){
                app.globalData.registerFlag = true;
              }else{
                app.globalData.registerFlag = false;
              }
              id:
              that.setData({
                bind:app.globalData.registerFlag,
                status:res.data.data.status,
                id:res.data.data.id,
                mobile:res.data.data.mobile,
                name:res.data.data.name
              })
              console.log("=======", app.globalData.registerFlag)
            }else{
              wx.showToast({
                title:"获取用户信息失败："+res.data.msg,
                icon: 'none',
                duration: 2000
              })
            }
          }
        })
        // == getUserInfo end
      }
    });
    //wx.login === end ===
  },
  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    this.onLoad()
  },
})